package cn.yangsen.simplebeanmanager.bean.html;

import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import cn.yangsen.simplebeanmanager.bean.html.itfc.Cleanable;
import cn.yangsen.simplebeanmanager.bean.html.itfc.SubmitAble;

import com.thoughtworks.xstream.annotations.XStreamAlias;
import com.thoughtworks.xstream.annotations.XStreamAsAttribute;

@XStreamAlias("select")
@ToString
public class Select extends Element implements SubmitAble, Cleanable
{
	@Getter
	@Setter
	@XStreamAsAttribute
	private String name;

	@Getter
	@Setter
	@XStreamAsAttribute
	private String onchange;

	@XStreamAsAttribute
	private String disabled;

	public void setDisabled(boolean disabled)
	{
		if (disabled)
		{
			this.disabled = "disabled";
		}
		else
		{
			this.disabled = null;
		}
	}

	public void addOnchange(String funtion)
	{
		if (onchange == null)
		{
			onchange = funtion;
		}
		else
		{
			onchange = onchange + ";" + funtion;
		}
	}

	@Override
	public void clean()
	{
		setElements(null);
	}
}
